<?php
namespace app\index\controller;

class Index
{
    public function index()
    {

    }

    public function maintenance()
    {
        $command_path = '';
        if (substr(php_uname(), 0, 7) == "Windows") {
            $command_path = ROOT_PATH . "vendor\\bin\\doctrine.bat";
        } else {
            $command_path = ROOT_PATH . "vendor\\bin\\doctrine";
        }
        if (substr(php_uname(), 0, 7) == "Windows") {
            $command_path .= ' orm:schema-tool:update --force --dump-sql';
            // pclose(popen("start /B " . $command_path, "r"));
            chdir(ROOT_PATH . 'vendor\\bin');
            exec($command_path, $ot);
            echo json_encode($ot);
        } else {
            exec($cmd . " > /dev/null &");
        }
    }
}
